/**
 * Created by Administrator on 2017/3/13 0013.
 */




Page1={
    Create:function() {
        var page = {};
        var whole = new PIXI.DisplayObjectContainer();
        var arrXY=[];

        var typeNo=1;
        var arrLiveBtn=[];
        var bl_sh=false;


        var bg=new PSP("bg");
        // whole.addChild(bg);
        // bg.blendMode=PIXI.BLEND_MODES.MULTIPLY;



        var op=new PSP("op");
        whole.addChild(op);


        var btn_viewChange=new Btn99(120,30,"视图切换");
        whole.addChild(btn_viewChange);
        btn_viewChange.getDownWord("返回");
        btn_viewChange.x=pixiStageW-250;
        btn_viewChange.y=200;

        var btn_viewTable=new Btn99(160,30,"表格呈现方式");
        whole.addChild(btn_viewTable);
        btn_viewTable.x=btn_viewChange.x-btn_viewTable.width-20;
        btn_viewTable.y=btn_viewChange.y-btn_viewTable.height-10;
        btn_viewTable.alpha=0;

        var btn_viewHelix=new Btn99(160,30,"螺旋呈现方式");
        whole.addChild(btn_viewHelix);
        btn_viewHelix.x=btn_viewChange.x-btn_viewHelix.width-20;
        btn_viewHelix.y=btn_viewChange.y;
        btn_viewHelix.alpha=0;

        var btn_viewGrid=new Btn99(160,30,"网格呈现方式");
        whole.addChild(btn_viewGrid);
        btn_viewGrid.x=btn_viewChange.x-btn_viewGrid.width-20;
        btn_viewGrid.y=btn_viewChange.y+btn_viewGrid.height+10;
        btn_viewGrid.alpha=0;

        arrXY.push(btn_viewTable.x);
        arrXY.push(btn_viewHelix.x);
        arrXY.push(btn_viewGrid.x);

        btn_viewChange.interactive=true;
        btn_viewChange.on("pointerdown",viewBtnShow);
        var bl_type=true;
        function viewBtnShow(){
            if(bl_type){
            btn_viewTable.x=arrXY[0]-40;
            btn_viewHelix.x=arrXY[1]-40;
            btn_viewGrid.x=arrXY[2]-40;

            TweenMax.to(btn_viewTable,0.5,{delay:0.0,alpha:1,x:arrXY[0],ease:Cubic.easeOut});
            TweenMax.to(btn_viewHelix,0.5,{delay:0.1,alpha:1,x:arrXY[1],ease:Cubic.easeOut});
            TweenMax.to(btn_viewGrid,0.5,{delay:0.2,alpha:1,x:arrXY[2],ease:Cubic.easeOut});
                bl_type=false;
                btn_viewTable.interactive=true;
                btn_viewHelix.interactive=true;
                btn_viewGrid.interactive=true;
                btnAppear(false,"part");
            }
            else{
                TweenMax.to(btn_viewTable,0.5,{delay:0.0,alpha:0,ease:Cubic.easeOut});
                TweenMax.to(btn_viewHelix,0.5,{delay:0.1,alpha:0,ease:Cubic.easeOut});
                TweenMax.to(btn_viewGrid,0.5,{delay:0.2,alpha:0,ease:Cubic.easeOut});
                bl_type=true;
                btn_viewTable.interactive=false;
                btn_viewHelix.interactive=false;
                btn_viewGrid.interactive=false;
                btnAppear(true,"part");
            }
        }
        btn_viewTable.interactive=false;
        btn_viewHelix.interactive=false;
        btn_viewGrid.interactive=false;

        btn_viewTable.on("pointerdown",viewChange);
        btn_viewHelix.on("pointerdown",viewChange);
        btn_viewGrid.on("pointerdown",viewChange);
        function viewChange(e){
            if(e.target==btn_viewTable){
                typeNo=1;
                document.dispatchEvent(new CustomEvent("viewChange",{detail:1}));
            }
            else  if(e.target==btn_viewHelix){
                typeNo=2;
                document.dispatchEvent(new CustomEvent("viewChange",{detail:2}));
            }
            else if(e.target==btn_viewGrid){
                typeNo=3;
                document.dispatchEvent(new CustomEvent("viewChange",{detail:3}));
            }
            reset();
            viewBtnShow();
        }

        //隐藏-显示连线图标
        var btn_showLine=new Btn99(120,30,"隐藏连线");
        whole.addChild(btn_showLine);
        btn_showLine.getDownWord("显示连线");
        btn_showLine.x=pixiStageW-250;
        btn_showLine.y=280;

        btn_showLine.interactive=true;
        btn_showLine.on("pointerdown",showOrHideLine);
        function showOrHideLine(){
            var ibl=btn_showLine.downState();
            btn_canMove.setGray(ibl);
            document.dispatchEvent(new CustomEvent("showOrHideLine",{detail:ibl}));
        }

        //激活拖动-保存坐标图标
        var btn_canMove=new Btn99(120,30,"激活拖动");
        whole.addChild(btn_canMove);
        btn_canMove.getDownWord("保存坐标");
        btn_canMove.x=pixiStageW-250;
        btn_canMove.y=360;
        btn_canMove.interactive=true;
        btn_canMove.on("pointerdown",canMoveOrNot);
        function canMoveOrNot(){
            if(btn_canMove.downState()){
                btn_showLine.setGray(false);
                btn_viewChange.setGray(false);
            }
            else{
                btn_showLine.setGray(true);
                btn_viewChange.setGray(true);
            }
            document.dispatchEvent(new CustomEvent("canMoveOrNot",{detail:btn_canMove.downState()}));
        }
        btn_canMove.setGray(false);

        //开启-停止自动播放按钮
        var btn_auto=new Btn99(120,30,"停止自动播放")
        whole.addChild(btn_auto);
        btn_auto.getDownWord("开启自动播放");
        btn_auto.x=pixiStageW-250;
        btn_auto.y=280;
        btn_auto.interactive=false;
        btn_auto.alpha=0;
        btn_auto.on("pointerdown",autoPlayOrNot);
        function autoPlayOrNot(){
                document.dispatchEvent(new CustomEvent("autoPlayOrNot"))
        }


        //隐藏-显示连线图标2(模式三中使用)
        var btn_showLine2=new Btn99(120,30,"隐藏连线");
        whole.addChild(btn_showLine2);
        btn_showLine2.getDownWord("显示连线");
        btn_showLine2.x=pixiStageW-250;
        btn_showLine2.y=360;
        btn_showLine2.interactive=false;
        btn_showLine2.alpha=0;
        btn_showLine2.on("pointerdown",showOrHideLine2);
        function showOrHideLine2(){
            var ibl=btn_showLine2.downState();
                document.dispatchEvent(new CustomEvent("showOrHideLine",{detail:ibl}));
        }

        function reset(){
            bl_sh=true;
            btn_auto.reset();
            btn_showLine.reset();
            btn_showLine2.reset();

            btn_viewTable.reset();
            btn_viewHelix.reset();
            btn_viewGrid.reset();

            btn_viewChange.reset();
        }

        var arr1=[];
        var arr2=[];
        var arr3=[];
        arrLiveBtn.push(arr1);
        arrLiveBtn.push(arr2);
        arrLiveBtn.push(arr3);
        arr1.push(btn_viewChange);
        arr1.push(btn_showLine);
        arr1.push(btn_canMove);
        arr2.push(btn_viewChange);
        arr2.push(btn_auto);
        arr2.push(false);
        arr3.push(btn_viewChange);
        arr3.push(btn_auto);
        arr3.push(btn_showLine2);

        function btnAppear(getBl,type){
            var z;
            if(type=="whole"){z=0;}
            else{z=1;}
            var group=arrLiveBtn[typeNo-1];
            for(;z<group.length;z++){
                if(group[z]) {
                if(getBl){
                        group[z].interactive = true;
                        group[z].alpha = 0;
                        group[z].x = pixiStageW -250 + 150 + z * 20;
                        // TweenMax.killTweensOf(group[z]);
                        TweenMax.to(group[z], 1, {delay: 0.15 * z, alpha: 1, x: pixiStageW -250, ease: Back.easeOut});
                }
                else{
                    group[z].interactive=false;
                    group[z].alpha=1;
                    group[z].x=pixiStageW-250;
                    // TweenMax.killTweensOf(group[z]);
                    TweenMax.to(group[z],1,{delay:0.15*z,alpha:0,x:pixiStageW-250+150+z*20,ease:Back.easeIn});
                }
                }
            }
        }






        page.DoIt=function(){

        }
        page.In=function(){
            btnAppear(true,"whole");
        }
        page.Out=function(){
            btnAppear(false,"whole");
        }

        page.ReturnWhole=function(){
            return whole;
        };

        return page;
    }
}
